import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class FuncComp extends StatefulWidget {
  const FuncComp({super.key, required this.label, this.onCallback});
  // 功能标签
  final String label;

  // 回调函数
  final VoidCallback? onCallback;

  @override
  State<FuncComp> createState() => _FuncCompState();
}

class _FuncCompState extends State<FuncComp> {
  late String label;
  @override
  void initState() {
    super.initState();
    label = widget.label;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 19, bottom: 19),
      decoration: BoxDecoration(
          border:
              Border(bottom: BorderSide(color: Colors.grey[200]!, width: 0.5))),
      child: GestureDetector(
        onTap: () {
          // 检查 onCallback 是否为 null
          if (widget.onCallback != null) {
            widget.onCallback!(); // 调用回调函数
          } else {
            print('onCallback is null');
          }
        },
        child: Row(
          children: [
            Expanded(
                child: Text(
              label,
              style: TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
            )),
            SvgPicture.asset('assets/ic_btn_more.svg'),
          ],
        ),
      ),
    );
  }
}
